<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>edit courses</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <link rel="icon" href="{{ url_for('static', filename='logo.png') }}" type="image/png">
    <style>
        :root {
            --primary-color: #4e73df;
            --secondary-color: #f8f9fc;
            --accent-color: #1cc88a;
        }

        body {
            padding: 0;
            margin: 0;
            background-image: url('/static/images/Background_image.jpeg');
            background-size: cover;
            background-attachment: fixed;
            background-position: center;
            min-height: 100vh;
            font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
        }
        .card {
            border: none;
            border-radius: 0.35rem;
            box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.1);
            background-color: rgba(255, 255, 255, 0.9);
        }

        .card-header {
            background-color: var(--primary-color);
            color: white;
            border-bottom: none;
            padding: 1rem 1.35rem;
            border-radius: 0.35rem 0.35rem 0 0 !important;
        }

        .card-title {
            font-weight: 700;
            color: white;
        }

        .form-control {
            padding: 0.75rem 1rem;
            border: 1px solid #d1d3e2;
            border-radius: 0.35rem;
        }

        .form-control:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
        }

        .btn-primary {
            background-color: var(--primary-color);
            border-color: var(--primary-color);
            padding: 0.5rem 1.5rem;
        }

        .btn-secondary {
            padding: 0.5rem 1.5rem;
        }
    </style>
</head>
<body>
    <div class="container-wrapper">
        <div class="container mt-5">
            <div class="row justify-content-center">
                <div class="col-xl-8 col-lg-9 col-md-10">
                    <div class="card">
                        <div class="card-header py-3">
                            <h4 class="m-0 font-weight-bold">
                                <i class="fas fa-edit mr-2"></i>编辑课程信息
                            </h4>
                        </div>
                        <div class="card-body">
                            <!-- 添加消息显示区域 -->
                                {% with messages = get_flashed_messages(with_categories=true) %}
                                    {% if messages %}
                                        {% for category, message in messages %}
                                            <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
                                                {{ message }}
                                                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                                    <span aria-hidden="true">&times;</span>
                                                </button>
                                            </div>
                                        {% endfor %}
                                    {% endif %}
                                {% endwith %}


                            <form action="{{ url_for('edit_course', course_id=course.course_id) }}" method="post">
                                <div class="form-group">
                                    <label for="course_name" class="font-weight-bold">课程名称</label>
                                    <input type="text" class="form-control" id="course_name" name="course_name" value="{{ course.course_name }}" required>
                                </div>

                                <div class="form-group">
                                    <label for="duration" class="font-weight-bold">上课时间</label>
                                        <input type="text" class="form-control" id="duration" name="duration"
                                        pattern="^([01]?[0-9]|2[0-3]):([0-5][0-9])-([01]?[0-9]|2[0-3]):([0-5][0-9])$"
                                        title="请输入有效的时间范围格式 (HH:MM-HH:MM)，例如 09:00-11:00" required>
                                    <small class="form-text text-muted">请输入时间范围 (HH:MM-HH:MM)，例如 09:00-11:00</small>
                                </div>

                                <div class="form-group">
                                    <label for="coach" class="font-weight-bold">教练</label>
                                    <input type="text" class="form-control" id="coach" name="coach" value="{{ course.coach }}" required>
                                </div>

                                <div class="form-group">
                                    <label for="price" class="font-weight-bold">价格</label>
                                    <div class="input-group">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text">¥</span>
                                        </div>
                                        <input type="number" class="form-control" id="price" name="price" value="{{ course.price }}" required>
                                    </div>
                                </div>

                                <div class="d-flex justify-content-between mt-4">
                                    <a href="{{ url_for('view_courses') }}" class="btn btn-secondary">
                                        <i class="fas fa-times mr-1"></i>取消
                                    </a>
                                    <button type="submit" class="btn btn-primary">
                                        <i class="fas fa-save mr-1"></i>保存更改
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>